package org.anderground.editor.gui.menubar;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.JMenuItem;
import javax.swing.filechooser.FileNameExtensionFilter;

@SuppressWarnings("serial")
public class AddDrawerMenuItem extends JMenuItem {

	public AddDrawerMenuItem() {
		super("Add android drawer");
		addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {

				openJarDialog();

			}

		});
	}

	private void openJarDialog() {
		JFileChooser fc = new JFileChooser();
		fc.setFileFilter(new FileNameExtensionFilter("Java Archive files",
				"jar"));

		if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
			File f = fc.getSelectedFile();
			// TODO
			// DrawersRegistry.loadDrawersFromFile(f);
		}
	}

}
